package com.lagou.edu.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;


/**
 * 封装handler方法相关的信息
 *
 * @author yingchengpeng
 */
public class Handler {

    /**
     * method.invoke(obj,)
     */
    private Object controller;

    /**
     * 具体的函数
     */
    private Method method;

    /**
     * 拥有权限的用户
     */
    private Set<String> users;

    /**
     * spring中url是支持正则的
     */
    private Pattern pattern;

    /**
     * 参数顺序,是为了进行参数绑定，key是参数名，value代表是第几个参数 <name,2>
     */
    private Map<String, Integer> paramIndexMapping;

    public Handler(Object controller, Method method, Set<String> users, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.users = users;
        this.pattern = pattern;
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Set<String> getUsers() {
        return users;
    }

    public void setUsers(Set<String> users) {
        this.users = users;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
